﻿using System;
using Eamon.MeituanDotnetSDK.api.common.request;
using Eamon.MeituanDotnetSDK.@enum;

namespace Eamon.MeituanDotnetSDK.api.common
{
    public abstract class AbstractAPI<T> : IAPI
    {
        protected IAPIRequest apiRequest;

        //public AbstractAPI(IAPIRequest apiRequest) // 这个写法更科学，但是为了兼容就算了
        //{
        //    this.apiRequest = apiRequest;
        //}
        public IAPIRequest getAPIRequest()
        {
            return apiRequest;
        }

        public virtual AuthenticateType getAuthenticateType() { return AuthenticateType.SIGN; } // 不需要了
        public virtual HttpMethodEnum getHttpMethod()
        {
            return HttpMethodEnum.POST;
        }
        public abstract string getHttpUrl(); // javasdk.ApiMeta.path
        public abstract string getMethod(); // javasdk.ApiMeta.apiName
        public virtual string getApiVersion()
        {
            return "10013";
        }
        public virtual int getBusinessId()
        {
            return 58;
        }
        public abstract Type getRequestClass();
        public virtual Type getResponseClass()
        {
            return typeof(T);
        }
        public virtual bool isNeedAuth() // javasdk.ApiMeta.needAuth
        {
            return true;
        }

        public void setAPIRequest(IAPIRequest apiRequest)
        {
            this.apiRequest = apiRequest;
        }
    }
}
